//
//  BaseRequest.m
//  TLKeepCredit
//
//  Created by mac on 2017/10/11.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "BaseRequest.h"
#import "AFNetworking.h"
@implementation BaseRequest


+(void)GET:(NSString *)urlString
parameters:(NSDictionary *)parame
   success:(void (^)(id responseObject,int code))success
   failure:(void (^)(NSError *error))failure {
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html", nil];
    [manager GET:kAPP_URL_H(urlString) parameters:parame progress:^(NSProgress * _Nonnull uploadProgress) {
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        if (success) {
            success(responseObject,1);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failure) {
            failure(error);
        }
    }];
}

+(void)POST:(NSString *)urlString
 parameters:(NSDictionary *)parame
    success:(void (^)(id responseObject,int code))success
    failure:(void (^)(NSError *error))failure {

    NSString *url = kAPP_URL_H(urlString);
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html", nil];
    [manager POST:url parameters:parame progress:^(NSProgress * _Nonnull uploadProgress) {
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (success) {
            success(responseObject,1);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failure) {
            failure(error);
        }
    }];
    
}
@end
